Omics - Analysis of large-scale biomolecular datasets
Introduction to Linux (KIMN20 - LTH)
2025-10-30
Introduction to Linux
Course date: 04 November 2025
Last modified: 2025-10-30
Welcome to Linux Commands! 🐧
This presentation will teach you the fundamental Linux commands you’ll need to navigate and work with the command line.
What we’ll cover:
Navigation commands (pwd, ls, cd, paths)
File operations (mkdir, touch, cp, mv, rm, tar)
Text processing (cat, grep, less, head, tail, nano)
System information (whoami, uname, df, top)
Package management
Getting help and shortcuts
What Linux is?
Linux is an Operating System
Linux is a free and open-source operating system that powers everything from smartphones to supercomputers.
Key Characteristics:
Kernel : The core of the OS that manages hardware and system resources
Distributions : Different “flavors” of Linux (Ubuntu, CentOS, Fedora, etc.)
Free Software : No licensing fees, source code available to everyone
Community-Driven : Developed collaboratively by volunteers worldwide
Why “Linux” vs “GNU/Linux”?
Linux refers specifically to the kernel (created by Linus Torvalds in 1991)
GNU/Linux refers to the complete operating system including GNU tools
In practice, people often just say “Linux”
Why Linux?
Command-Line Power : Perfect for automation, pipelines, and complex workflows
Multi-User Systems : Multiple researchers can work simultaneously on shared servers
Scientific Software : Thousands of bioinformatics tools (R, Python, sequencing software)
Stability & Reliability : Runs 24/7 without crashes - critical for long analyses
Free & Open-Source : No licensing costs, complete source code access
Industry Standard : Powers 100% of top 500 supercomputers and cloud platforms
Getting Started
Opening the Terminal
Windows : Git Bash (or use WSL)
macOS : Press Cmd + Space, type “Terminal”, press Enter
Linux : Press Ctrl + Alt + T
Your First Command
# This is a comment - it won't execute
echo "Hello, Linux!"
Try running this command in your terminal!
exit - Exit the Terminal
Closes the current shell session.
Navigation Commands
pwd - Print Working Directory
Shows your current location in the file system.
ls - List Directory Contents
Lists files and directories in the current directory.
ls
ls -l # Long listing format
ls -a # Show hidden files
cd - Change Directory
Changes your current working directory.
cd directory_name # Relative path
cd /absolute/path # Absolute path
cd .. # Go up one directory
cd ~ # Go to home directory
cd - # Go to previous directory
Absolute vs Relative Paths
Absolute paths : Start with / and specify the full path from root
Relative paths : Start from current directory, use . for current, .. for parent
# Absolute path
cd /home/user/documents
# Relative path
cd documents # If you're in /home/user/
cd ../sibling # Go to sibling directory
File Operations
mkdir - Make Directory
Creates a new directory.
mkdir my_folder # Create single directory
mkdir -p parent/child/grandchild # Create nested directories
touch - Create Empty File
touch new_file.txt # Create single empty file
touch file1.txt file2.txt file3.txt # Create multiple files
cp - Copy Files
cp source.txt destination.txt # Copy single file
cp -r source_dir destination_dir # Copy directory recursively
More File Operations
mv - Move/Rename Files
mv old_name.txt new_name.txt # Rename
mv file.txt /path/to/directory/ # Move
rm - Remove Files
rm file.txt
rm -r directory/ # Remove directory and all its contents recursively
rm -i file.txt # Interactive mode
⚠️ Warning: rm -rf / will delete everything! Be careful!
tar - Archive Files
Create and extract compressed archives.
# Create archive
tar -czf archive.tar.gz directory/
# Extract archive
tar -xzvf archive.tar.gz
# List archive contents
tar -tzf archive.tar.gz
Text Processing
cat - Concatenate and Display
cat file.txt # Display single file
cat file1.txt file2.txt # Display multiple files
grep - Search Text
grep "search_term" file.txt # Search in single file
grep -r "pattern" /path/to/search/ # Search recursively
grep -i "case_insensitive" file.txt # Case-insensitive search
less - View File Contents
Views file contents one page at a time (better than cat for large files).
less file.txt
# Navigation: space (next page), b (previous), q (quit)
head - Show Beginning of File
Shows the first few lines of a file.
head file.txt
head -n 20 file.txt # First 20 lines
tail - Show End of File
Shows the last few lines of a file.
tail file.txt
tail -n 20 file.txt # Last 20 lines
tail -f file.txt # Follow file (real-time updates)
nano - Simple Text Editor
Basic command-line text editor.
nano file.txt
# Ctrl+O (save), Ctrl+X (exit), Ctrl+W (search)
Package Management
Ubuntu/Debian (apt)
# sudo: Run commands with superuser (administrator) privileges
sudo apt update
sudo apt install package_name
sudo apt remove package_name
CentOS/RHEL (yum/dnf)
# sudo: Run commands with superuser (administrator) privileges
sudo yum install package_name
sudo yum remove package_name
macOS (brew)
# brew: Homebrew package manager for macOS
brew install package_name
brew uninstall package_name
Useful Shortcuts
Command Line Shortcuts
↑/↓ - Navigate command history
Tab - Auto-complete commands/files
Ctrl + C - Cancel current command
Ctrl + L - Clear screen
Ctrl + A - Go to beginning of line
Ctrl + E - Go to end of line
Wildcards
Wildcards are special characters that allow you to match multiple files or directories based on patterns, making it easier to work with groups of files.
* - Matches any characters
? - Matches single character
[abc] - Matches any of a, b, or c
Example:
ls * .txt # List all files ending with .txt
cp file? .txt backup/ # Copy files like file1.txt, file2.txt to backup/
ls linux_practice/* .txt # List all .txt files in linux_practice
Getting Help
man - Manual Pages
# man: Display detailed manual pages for commands
man ls
–help Flag
# --help: Show built-in help information for most commands
ls --help
tldr - Simplified Help
# tldr: Community-driven simplified command explanations
tldr ls
Common Mistakes & Tips
Common Errors
Permission denied - Use sudo for admin tasks
Command not found - Check spelling, PATH
No such file or directory - Verify paths
Best Practices
Use ls before rm to double-check
Use man or --help for unfamiliar commands
Backup important files before operations
Use tab completion to avoid typos
Quiz Time! 🧠
Question 1
Which command shows your current directory? - A) ls - B) pwd - C) cd
Question 2
How do you create a new directory? - A) touch newdir - B) mkdir newdir - C) cp newdir
Question 3
What’s the safest way to delete a file? - A) rm file.txt - B) rm -rf file.txt - C) rm -i file.txt
Quiz Time! 🧠
Answers: 1-B, 2-B, 3-C
Next Steps
What to Learn Next
File permissions (chmod, chown)
Process management (ps, kill)
Advanced text editors (vim, emacs)
Shell scripting basics
Networking commands (ping, curl, ssh)
User management (useradd, passwd)
Resources
Thank You!
You’ve completed the basic Linux commands tutorial!
Remember:
Practice regularly
Use man for help
Start with simple commands
Build complexity gradually
Questions?
Feel free to ask your instructor or classmates!
🐧 Happy Linux learning! 🐧
Practice Time! 💻
Exercise 1: Navigation
Open your terminal
Check your current directory with pwd
List the contents with ls
Create a new directory called linux_practice
Change into that directory
pwd
ls -la
mkdir -p linux_practice
cd linux_practice
Exercise 2: File Operations
Create a text file called notes.txt
Add some text to it using echo "Hello Linux" > notes.txt
Display the contents with cat
Copy the file to backup.txt
List the directory contents
echo "Hello Linux" > notes.txt
cat notes.txt
cp notes.txt backup.txt
ls -la